﻿using System;
using System.Collections.Generic;
using System.Text;

namespace _018传值_输出_引用_数组_具名_可选参数_4__Ref关键字
{
    internal class Program
    {
        static void Main(string[] args)
        {
            //int y = 1;
            //IWantSideEffe(ref y);
            //Console.WriteLine(y);//101


            Student outterStu = new Student() { Name = "Human" };
            Console.WriteLine("HashCode={0},Name={1}", outterStu.GetHashCode(), outterStu.Name);
            IWantSideEffect(ref outterStu);
            Console.WriteLine("HashCode={0},Name={1}", outterStu.GetHashCode(), outterStu.Name);

        }

        //static void IWantSideEffe(ref int x)
        //{
        //    x = x + 100;
        //}




        static void IwantSideEffect(ref Student stu)
        {
            stu = new Student() { Name = "People"};
            Console.WriteLine("HashCode={0},Name={1}在方法里面",stu.GetHashCode(),stu.Name);
        }


        static void IWantSideEffect(ref Student stu) {
            stu.Name = "People";
            Console.WriteLine();
            Console.WriteLine("HashCode={0},Name={1}在方法里面", stu.GetHashCode(), stu.Name);
        }
    }

    class Student {

        public string Name { get; set; }
    }
}
